using System;

namespace Storage.Core
{
	internal class ReadByIdQuery : IStorageQuery
	{
		public ReadByIdQuery(Guid id)
		{
			Id = id;
		}

		public byte[] Serialize()
		{
			var serializer = new FastBinarySerializer(16 + sizeof(byte));
			serializer.Write(StorageOpCodes.ReadById);
			serializer.Write(Id);
			return serializer.Buffer;
		}

		public static ReadByIdQuery Deserialize(IBinaryDeserializer ds)
		{
			return new ReadByIdQuery(ds.ReadGuid());
		}

		public Guid Id { get; private set; }
	}
}